package com.homework.ch10;

/**
 * @author yuxi
 * @version 1.0
 * @date 2025/10/14
 * @Description:
 */

public class Test4{
    public static void main(String[] args) {
        //匿名内部类或者lambda创建线程
        Thread t1=new Thread(){
            public void run(){
                System.out.println("t1线程运行");
            }
        };
        //t2等待t1执行完毕后再执行t2自己
        Thread t2=new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    t1.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("t2线程运行");
            }
        });
        Thread t3=new Thread(()->{
            try {
                t2.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t3线程运行");
        });
        t1.start();
        t2.start();
        t3.start();
    }
}
